1. Field of the Invention
The present invention is directed to computer systems. More particularly, it is directed to graphical image processing.
2. Description of the Related Art
Traditionally, dynamic foreground image elements, such as cursors or user-defined bounding lines, are drawn using an XOR drawing mode that allows the same drawing function to both draw and erase the foreground image. XOR is a bitwise logical operation on two operands that results in a logical value of true if and only if one of the operands, but not both, has a value of true. The XOR operation is performed over each bit in the operands. Performing the same XOR operation on the same operands twice results in the original operands. Thus, when a cursor is drawn using an XOR mode, that cursor may be erased by drawing the same cursor again in the same location. When drawing foreground images using XOR, a foreground image is typically drawn into the frame buffer and therefore changes the actual background image accordingly. Thus, the background image must be restored whenever the foreground image is to be erased. However, XOR-based cursor drawing frequently causes color shifts that may interfere with the overall look of the image and that may also cause a user difficulty when working with an image, such as in a graphics or image drawing application.
When using XOR drawing, in order to ensure contrast between a foreground image element, such as a cursor, and the background, generally a double edge, one black and one white is used with the XOR drawing so that the edge of the cursor is visible over varying background colors. However, using such a double edge may increase the amount of the background image that is being covered by the foreground image element.
A traditional black-over XOR is performed by XORing all 1s over an image. For example, in an 8-bit deep frame buffer using RGBX representation (alpha in the frame buffer is generally ignored) if the overlay value at a location x,y is set, then pixel x,y is set to pixel x,y XOR 0xFFFFFF00.
AddOver is a variant of XOR that uses 0x80 instead of 0xFF per component. When using AddOver parts that are XORed with 0x80 are guaranteed to always change. AddOver can be thought of as “if (r<½ intensity) r+=half intensity else f−=half intensity.” Like XOR, AddOver may generate color shifts and must be performed a second time undo or erase the effects of a first AddOver operation.